Skip to content

Conversation

@jj22ee
Copy link
Contributor

@jj22ee jj22ee commented Oct 1, 2024

Issue #, if available:
Short-term workaround to avoid Upsteam OTel emitting logs such as:

  • OTEL_TRACES_SAMPLER value "xray invalid, defaulting to always_on".

OTel dependencies will always load a default Sampler configuration. Although unused, that load process will read the OTEL_TRACES_SAMPLER value and may emit the above log, which is unwanted for xray value. xray does not yet exist in upstream OTel, but in ADOT, we define it as valid. Thus we temporarily remove this env var to avoid the unwanted log only if xray is set in that Env Var.

When xray sampler is available in upstream, this workaround should be removed.

Description of changes:

  • Unset process.env.OTEL_TRACES_SAMPLER if equal to xray, then use boolean variable to enable xray sampler instead of Env Var. Restore Env Var value later.
  • Add log to state that AWS XRay Sampler enabled, if enabled

Testing:

  • Tested that the log OTEL_TRACES_SAMPLER value "xray invalid, defaulting to always_on". doesn't appear in this repo's sample app.

Before:

node --require '@aws/aws-distro-opentelemetry-node-autoinstrumentation/register' sample-app-express-server.js
'pollingInterval' is undefined or too small. Defaulting to 300 seconds
OTEL_TRACES_EXPORTER is empty. Using default otlp exporter.
AWS Application Signals enabled.
AWS Application Signals metrics export interval capped to 60000
OTEL_LOGS_EXPORTER is empty. Using default otlp exporter.
OTEL_TRACES_SAMPLER value "xray invalid, defaulting to always_on".
Setting TraceProvider for instrumentations at the end of initialization
OTEL_TRACES_SAMPLER value "xray invalid, defaulting to always_on".
OTEL_TRACES_SAMPLER value "xray invalid, defaulting to always_on".
...
OTEL_TRACES_SAMPLER value "xray invalid, defaulting to always_on".
AWS Distro of OpenTelemetry automatic instrumentation started successfully
Listening for requests on http://localhost:8080
...
OTEL_TRACES_SAMPLER value "xray invalid, defaulting to always_on".
OTEL_TRACES_SAMPLER value "xray invalid, defaulting to always_on".
OTEL_TRACES_SAMPLER value "xray invalid, defaulting to always_on".
OTEL_TRACES_SAMPLER value "xray invalid, defaulting to always_on".

After:

node --require '@aws/aws-distro-opentelemetry-node-autoinstrumentation/register' sample-app-express-server.js
AWS XRay Sampler enabled
'pollingInterval' is undefined or too small. Defaulting to 300 seconds
OTEL_TRACES_EXPORTER is empty. Using default otlp exporter.
AWS Application Signals enabled.
AWS Application Signals metrics export interval capped to 60000
OTEL_LOGS_EXPORTER is empty. Using default otlp exporter.
Setting TraceProvider for instrumentations at the end of initialization
AWS Distro of OpenTelemetry automatic instrumentation started successfully
Listening for requests on http://localhost:8080

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@jj22ee jj22ee requested a review from a team as a code owner October 1, 2024 19:11
@pxaws pxaws merged commit f3d5edb into main Oct 2, 2024
8 checks passed
@pxaws pxaws deleted the avoid-confusing-otel-log branch October 2, 2024 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants